import request from '@neu/biz-core/utils/request'
import qs from 'qs'
const baseUrl = 'dcom/api/w/workDaily'

export const list = (params) => {
  return request({
    url: baseUrl,
    params,
    method: 'get'
  })
}

export const page = (params) => {
  return request({
    url: baseUrl + '/p',
    params,
    method: 'get',
    paramsSerializer: params => qs.stringify(params, { indices: false })
  })
}

export const create = (data) => {
  return request({
    url: baseUrl,
    data,
    method: 'post'
  })
}

export const remove = (id) => {
  return request({
    url: baseUrl + '/' + id,
    method: 'delete'
  })
}

export const detail = (id) => {
  return request({
    url: baseUrl + '/' + id,
    method: 'get'
  })
}

export const update = (id, data) => {
  return request({
    url: baseUrl + '/' + id,
    data,
    method: 'put'
  })
}

export const exportExcel = (params) => {
  return request({
    url: baseUrl + '/export',
    params,
    method: 'get',
    responseType: 'blob',
    headers: {
      'Content-Type': 'application/octet-stream'
    }
  })
}

export const todayStats = () => {
  return request({
    url: baseUrl + '/stats',
    method: 'get'
  })
}

export const importExcelUrl = baseUrl + '/import'

export const template = (params) => {
  return request({
    url: baseUrl + '/template',
    params,
    timeout: 120000,
    method: 'get',
    responseType: 'blob',
    headers: {
      'Content-Type': 'application/octet-stream'
    }
  })
}

export const report = (params) => {
  return request({
    url: baseUrl + '/stats/report',
    params,
    method: 'get'
  })
}

export const exportReport = (params) => {
  return request({
    url: baseUrl + '/stats/export',
    params,
    method: 'get',
    responseType: 'blob',
    headers: {
      'Content-Type': 'application/octet-stream'
    }
  })
}

export const serviceTimeTotal = () => {
  return request({
    url: baseUrl + '/service/time/total',
    method: 'get'
  })
}

export const getServiceSummaryOfWorker = (year, type) => {
  return request({
    url: baseUrl + '/service/summary/' + year + '/' + type,
    method: 'get'
  })
}

export const uploadFileUrl = '/dcom/api/w/files/upload'

export const downloadFileUrl = (fsId) => {
  return '/dcom/api/w/files/download/' + fsId
}
